﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Linq;

namespace TheOutfield.UmbExt.PrivateMessaging.Util
{
    public static class XmlExt
    { 
        public static XElement RemoveAllNamespaces(this XElement xmlDocument)
        {
            if (!xmlDocument.HasElements)
            {
                XElement xElement = new XElement(xmlDocument.Name.LocalName.ToLower());
                xElement.Value = xmlDocument.Value;
                return xElement;
            }
            return new XElement(xmlDocument.Name.LocalName.ToLower(), xmlDocument.Elements().Select(el => RemoveAllNamespaces(el)));
        }
    }
}